home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 January / PC Plus Super CD No55a (PCP-147A-1-99) (Disc 1) (1998).iso / linux / developers / visualtcl / windows / vtcl / lib / do.tcl < prev    next >
Encoding:
Text File  |  1997-04-09  |  2.0 KB  |  66 lines

  1. ##############################################################################
  2. # $Id: do.tcl,v 1.2 1997/04/09 13:13:01 stewart Exp $
  3. #
  4. # do.tcl - procedures to manage do and undo actions
  5. #
  6. # Copyright (C) 1996-1997 Stewart Allen
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ##############################################################################
  23. #
  24.  
  25. proc vTcl:passive_push_action {do undo} {
  26.     global vTcl
  27.     incr vTcl(change) 1
  28.     incr vTcl(action_index)
  29.     set vTcl(action_limit) $vTcl(action_index)
  30.     set vTcl(action,$vTcl(action_index),do) $do
  31.     set vTcl(action,$vTcl(action_index),undo) $undo
  32. }
  33.  
  34. proc vTcl:push_action {do undo} {
  35.     global vTcl
  36.     vTcl:passive_push_action $do $undo
  37.     eval $do
  38. }
  39.  
  40. proc vTcl:pop_action {} {
  41.     global vTcl
  42.     incr vTcl(change) -1
  43.     if { $vTcl(action_index) >= 0 } {
  44.         vTcl:destroy_handles
  45.         eval $vTcl(action,$vTcl(action_index),undo)
  46.         incr vTcl(action_index) -1
  47.         vTcl:setup_bind_tree .
  48.     } else {
  49.         vTcl:dialog "Nothing to undo!"
  50.     }
  51. }
  52.  
  53. proc vTcl:redo_action {} {
  54.     global vTcl
  55.     incr vTcl(change) 1
  56.     if { $vTcl(action_index) < $vTcl(action_limit) } {
  57.         vTcl:destroy_handles
  58.         incr vTcl(action_index) 1
  59.         eval $vTcl(action,$vTcl(action_index),do)
  60.         vTcl:setup_bind_tree .
  61.     } else {
  62.         vTcl:dialog "Nothing to redo!"
  63.     }
  64. }
  65.  
  66.